package cn.yudao.ymcc.mq.consumer;


import cn.yudao.ymcc.service.IPayOrderService;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
* @Title:
* @Description: 订单超时处理
* @Author: Mr.Jia
* @Version: 1.0
* @Date:  2022/8/21 19:59
* @Parameters:
* @Return
*/
@Component
@RocketMQMessageListener(consumerGroup="service-alipay-level-consumer",
        topic="topic-order-level",
        selectorExpression="tags-order-level",
        messageModel = MessageModel.BROADCASTING) // 广播模式
public class PayOrderLevelConsumer implements RocketMQListener<MessageExt> {

    @Autowired
    private IPayOrderService payOrderService;



    @Override
    public void onMessage(MessageExt message) {

        byte[] body = message.getBody();
        String orderNo = new String(body, StandardCharsets.UTF_8);
        // 调用方法执行业务 -- 不报错会自动完成签名
        payOrderService.PayOrderLevel(orderNo);
    }
}
